#%RAML 0.8
---
title: support-logging
version: "1.1.x"
baseUri: "http://localhost:48061/api"
protocols: [ HTTP ]

documentation:
  - title: Welcome
    content: |
      Welcome to the EdgeX Foundry Logging Microservice API Documentation.

schemas:
  - LogEntry: |
      {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "LogEntry Schema",
        "type": "object",
        "properties": {
          "originService": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "logLevel": {
            "enum": ["TRACE","DEBUG","INFO","WARN","ERROR"]
          },
          "created": {
            "description": "The creation timestamp",
            "type": "integer",
            "minimum": 0
          }
        },
        "required": ["originService","message","logLevel"]
      }
/v1/logs:
  post:
    description: Create a new LogEntry
    body:
      application/json:
        schema: LogEntry
        example: |
          {
            "logLevel": "WARN",
            "originService": "service1",
            "message": "Hello, Logging Service!"
          }
    responses:
      202:
        description: accepted to clients with timestamp being accepted.
      400:
        description: creation request is malformed
  /{limit}:
    uriParameters:
      limit:
        type: number
        description: the maximum number of records to fetch
        example: 10
    get:
      responses:
        413:
          description: if the number of events exceeds the current max limit
        500:
          description: for unknown or unanticipated issues.
        200:
          description: list a collection of LogEntry - limited in size by the limit parameter
          body:
            application/json:
              schema: array
              example: |
                [
                  {
                    "logLevel": "WARN",
                    "originService": "service1",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494527
                  },
                  {
                    "logLevel": "INFO",
                    "originService": "service2",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494528
                  }
                ]
  /{start}/{end}/{limit}:
    uriParameters:
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
      limit:
        type: number
        description: the maximimum number of records to fetch
        example: 10
    get:
      responses:
        413:
          description: if the number of events exceeds the current max limit
        500:
          description: for unknown or unanticipated issues.
        200:
          description: list a collection of LogEntry created between the specified start and end dates - limited in size by the limit parameter
          body:
            application/json:
              schema: array
              example: |
                [
                  {
                    "logLevel": "WARN",
                    "originService": "service1",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494527
                  },
                  {
                    "logLevel": "INFO",
                    "originService": "service2",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494528
                  }
                ]
  /originServices/{originServices}/{start}/{end}/{limit}:
    uriParameters:
      originServices:
        type: string
        description: accepting multiple originServices separated by comma
        example: service1,service2,service3
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
      limit:
        type: number
        description: the maximum number of records to fetch
        example: 10
    get:
      responses:
        413:
          description: if the number of events exceeds the current max limit
        500:
          description: for unknown or unanticipated issues.
        200:
          description: list a collection of LogEntry matching any of the specified originServices and being created between the specified start and end dates - limited in size by the limit parameter
          body:
            application/json:
              schema: array
              example: |
                [
                  {
                    "logLevel": "WARN",
                    "originService": "service1",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494527
                  },
                  {
                    "logLevel": "INFO",
                    "originService": "service2",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494528
                  }
                ]
  /keywords/{keywords}/{start}/{end}/{limit}:
    uriParameters:
      keywords:
        type: string
        description: accepting multiple keywords separated by comma
        example: keyword1,keyword2,keyword3
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
      limit:
        type: number
        description: the maximum number of records to fetch
        example: 10
    get:
      responses:
        413:
          description: if the number of events exceeds the current max limit
        500:
          description: for unknown or unanticipated issues.
        200:
          description: list a collection of LogEntry whose message containing any of the specified keywords and being created between the specified start and end dates - limited in size by the limit parameter
          body:
            application/json:
              schema: array
              example: |
                [
                  {
                    "logLevel": "WARN",
                    "originService": "service1",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494527
                  },
                  {
                    "logLevel": "INFO",
                    "originService": "service2",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494528
                  }
                ]
  /logLevels/{logLevels}/{start}/{end}/{limit}:
    uriParameters:
      logLevels:
        type: string
        description: accepting multiple logLevels separated by comma
        example: ERROR,WARN,INFO,DEBUG,TRACE
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
      limit:
        type: number
        description: the maximum number of records to fetch
        example: 10
    get:
      responses:
        413:
          description: if the number of events exceeds the current max limit
        500:
          description: for unknown or unanticipated issues.
        200:
          description: list a collection of LogEntry matching any of the specified logLevels and being created between the specified start and end dates - limited in size by the limit parameter
          body:
            application/json:
              schema: array
              example: |
                [
                  {
                    "logLevel": "WARN",
                    "originService": "service1",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494527
                  },
                  {
                    "logLevel": "INFO",
                    "originService": "service2",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494528
                  }
                ]
  /logLevels/{logLevels}/originServices/{originServices}/{start}/{end}/{limit}:
    uriParameters:
      logLevels:
        type: string
        description: accepting multiple logLevels separated by comma
        example: ERROR,WARN,INFO,DEBUG,TRACE
      originServices:
        type: string
        description: accepting multiple originServices separated by comma
        example: service1,service2,service3
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
      limit:
        type: number
        description: the maximum number of records to fetch
        example: 10
    get:
      responses:
        413:
          description: if the number of events exceeds the current max limit
        500:
          description: for unknown or unanticipated issues.
        200:
          description: list a collection of LogEntry matching any of the specified logLevels, originServices, and also being created between the specified start and end dates - limited in size by the limit parameter
          body:
            application/json:
              schema: array
              example: |
                [
                  {
                    "logLevel": "WARN",
                    "originService": "service1",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494527
                  },
                  {
                    "logLevel": "INFO",
                    "originService": "service2",
                    "message": "Hello, Logging Service!",
                    "created": 1469175494528
                  }
                ]
  /{start}/{end}:
    uriParameters:
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
    delete:
      responses:
        200:
          description: count of the number of LogEntry being deleted
        503:
          description: for unknown or unanticipated issues.
  /originServices/{originServices}/{start}/{end}:
    uriParameters:
      originServices:
        type: string
        description: accepting multiple originServices separated by comma
        example: service1,service2,service3
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
    delete:
      responses:
        200:
          description: count of the number of LogEntry being deleted
        500:
          description: for unknown or unanticipated issues.
  /keywords/{keywords}/{start}/{end}:
    uriParameters:
      keywords:
        type: string
        description: accepting multiple keywords separated by comma
        example: keyword1,keyword2,keyword3
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
    delete:
      responses:
        200:
          description: count of the number of LogEntry being deleted
        500:
          description: for unknown or unanticipated issues.
  /logLevels/{logLevels}/{start}/{end}:
    uriParameters:
      logLevels:
        type: string
        description: accepting multiple logLevels separated by comma
        example: ERROR,WARN,INFO,DEBUG,TRACE
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
    delete:
      responses:
        200:
          description: count of the number of LogEntry being deleted
        500:
          description: for unknown or unanticipated issues.
  /logLevels/{logLevels}/originServices/{originServices}/{start}/{end}:
    uriParameters:
      logLevels:
        type: string
        description: accepting multiple logLevels separated by comma
        example: ERROR,WARN,INFO,DEBUG,TRACE
      originServices:
        type: string
        description: accepting multiple originServices separated by comma
        example: service1,service2,service3
      start:
        type: number
        description: start date in long form
        example: 1469175494521
      end:
        type: number
        description: end date in long form
        example: 1469175499899
    delete:
      responses:
        200:
          description: count of the number of LogEntry being deleted
        500:
          description: for unknown or unanticipated issues.
  /removeold/age/{age}:
    uriParameters:
      age:
        type: number
        description: minimum age in milliseconds (from created timestamp) a LogEntry should be in order to be removed
        example: 604800000
    delete:
      responses:
        200:
          description: count of the number of LogEntry being deleted
        500:
          description: for unknown or unanticipated issues.
/v1/ping:
    displayName: Ping Resource
    description: example - http://localhost:48061/api/v1/ping
    get:
        description: Test service providing an indication that the service is available.
        displayName: service up check
        responses:
            "200":
                description: return value of "pong"
            "503":
                description: for unknown or unanticipated issues
/v1/config:
    displayName: Config Resource
    description: Example - http://localhost:48061/api/v1/config
    get:
        description: Fetch the current state of the service's configuration.
        responses:
            "200":
                description: The service's configuration as JSON document
/version:
    displayName: Edgex API Version
    description: Example - http://localhost:48061/api/version
    get:
        description: Get the API version
        responses:
            "200":
                description: The service's API version as JSON document
                body:
                  application/json:
                    example:  '{"version":"1.1.0"}'
